package com.college.eduService.controller;

import com.college.commonutil.result.Result;
import com.college.eduService.entity.vo.OneSubject;
import com.college.eduService.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Api(description="课程分类管理")
@RestController
@RequestMapping("/eduservice/Subject")
@CrossOrigin
public class EduSubjectController {
    @Autowired
    private EduSubjectService subjectService;

    //查询课程分类表所有数据
    @GetMapping("findAll")
    @ApiOperation(value="查询所有")
    private Result findAllSubject(){
        //调用service的方法实现查询所有
        List<OneSubject> list = subjectService.getAll();
        return Result.ok().data("items",list);
    }

    //添加课程分类
    @PostMapping("saveSubject")
    @ApiOperation(value="添加课程分类")
    //获取上传过来的文件，把文件读取出来
    private Result saveSubject(MultipartFile file){
        subjectService.saveSubject(file,subjectService);
        return Result.ok();
    }
}
